C#与三菱PLC通讯源码,PLC自动读取数值 public static void BulkReadRenderResult(HslCommunication.Core.IReadWriteNet readWrite, TextBox addTextBox, TextBox lengthTextBox, TextBox resultTextBox)
{
/*OperateResult<byte[]> read = readWrite.Read(addTextBox.Text, ushort.Parse(lengthTextBox.Text));
if (read.IsSuccess)
{
//resultTextBox.Text = "Result:" HslCommunication.BasicFramework.SoftBasic.ByteToHexString(read.Content);
resultTextBox.Text = HslCommunication.BasicFramework.SoftBasic.ByteToHexString(read.Content);
DemoUtils.Res = resultTextBox.Text;
}
*/
// MARK 2019-08-07
try
{
OperateResult<byte[]> read = readWrite.Read(addTextBox.Text, ushort.Parse(lengthTextBox.Text));
if (read.IsSuccess)
{
//resultTextBox.Text = "Result:" HslCommunication.BasicFramework.SoftBasic.ByteToHexString(read.Content);
resultTextBox.Text = HslCommunication.BasicFramework.SoftBasic.ByteToHexString(read.Content);
DemoUtils.Res = resultTextBox.Text;
}
else
{
MessageBox.Show("Read Failed:" read.ToMessageShowString());
}
}
catch (Exception ex)
{
MessageBox.Show("Read Failed:" ex.Message);
}
}
评论